from PySide6.QtCore import QThread, Signal
from PySide6.QtWidgets import QApplication, QMainWindow


class WorkerSignals(QMainWindow):
    finished = Signal(object)


class Worker(QThread):
    finished = Signal(object)
    def __init__(self, parent=None):
        super().__init__(parent)
        self.signals = WorkerSignals()

    def run(self):
        # 这里执行一些耗时的任务
        result = self.some_expensive_calculation()
        self.finished.emit(result)

    def some_expensive_calculation(self):
        # 这里是一个示例函数，实际应替换为你的计算密集型任务
        return '曞珀斯'


class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.worker = Worker()
        self.w = self.worker.finished.connect(self.handle_finished)
        self.worker.start()

    def handle_finished(self, result):
        print(f"计算结果: {result}")
        return result

    def good(self):
        print(self.w)


# 应用程序入口
app = QApplication([])
window = MainWindow()
window.show()
app.exec()